#include <sys/style.hpp>
#include <sys/allocator.hpp>
#include <global/print.hpp>
int Allocator::find_free_size(int index)
{
  int i=2;
  while(space[index+i]==space[index+i+1]){i++;}
  if(space[index+i+1]==READPROOF_LOW && space[index+i+2]==READPROOF_HIGH){
    i-=2; // prevent from eating others' cookie
  }
  return i+1;
}  

bool Allocator::check_readproof(int index) //返回true,如果我们的FREE_VALUE不在范围内。
{
  for(int i=1,len=index;i<len;i++){
    if(space[index-i]==READPROOF_HIGH && space[index-i-1]==READPROOF_LOW){
      type::u16* sizevalue_ptr=(type::u16*)&space[index-i-3];
      if(*sizevalue_ptr<i){     // draw a diagram and then it is clear
        return true;
      }  
      else{
        return false;
      }  
    }
  }
  print::printk("READPROOF Not Found!\n");
  return true;
} 
